<include file="Inc/html_header" />
<div class="searchBox mySelect">
    <a href="<?php echo U('group/group_add'); ?>" class="btn btn-primary">添加分组</a>
</div>
<div class="mtop10">
	<table class="table table-bordered table-hover">
        <thead>
            <tr>
                <th width="40">ID</th>
                <th>分组名称</th>
                <th width="60">状态</th>
                <th width="90">操作</th>
            </tr>
        </thead>
        <tbody>
            <?php
            if( ! empty($list)){
                foreach($list as $v){
                    $v['group_id'] = intval($v['group_id']);
                    $v['group_pid'] = intval($v['group_pid']);
                    $v['st'] = intval($v['st']);
                    $v['group_depth'] = intval($v['group_depth']);
            ?>
            <tr>
                <td class="tdf"><?php echo $v['group_id'];?></td>
                <td <?php if($v['group_pid'] === 0){echo 'class="bgc_eaf7fe"';}?>><?php echo str_repeat('&nbsp;', 9*$v['group_depth']).$v['group_name'];?></td>
                <td><span class="c_p" onclick="groupStatus(<?php echo $v['group_id'];?>, <?php echo (1-$v['st']);?>)"><?php if($v['st'] === 1){echo '<span class="color_1">正常</span>';}else{echo '<span class="color_0">禁用</span>';}?></span></td>
                <td>
                    <a href="<?php echo U('group/group_del', array('group_id'=>$v['group_id']));?>" onclick="javascript:return confirm('提示：您确定要删除吗？')">删除</a> /
                    <a href="<?php echo U('group/group_edit', array('group_id'=>$v['group_id']));?>">修改</a>
                </td>
            </tr>
            <?php }}else{?>
            <tr>
                <td colspan="4">没有数据</td>
            </tr>
            <?php }?>
        </tbody>
	</table>
</div>
<script type="text/javascript">
    function groupStatus(group_id, st)
    {
        if( ! confirm('确认？')){ return false; }
        $.ajax({
            url:'<?php echo U('group/ajax_group_st');?>',
            data:({'group_id':group_id, 'st':st}),
            type:'post',
            dataType:'json',
            success:function(msg){
                if(msg.st == 'y'){
                    location.reload();
                }else{
                    alert(msg.note);
                }
            },
            error:function(){
                alert('网络繁忙，请稍后重试');
            }
        })
    }
</script>
<include file="Inc/html_footer" />